package com.skytech.tax.customsdatawarehouse.singlewindow.dictcategory.resource;

import com.skytech.tax.customsdatawarehouse.singlewindow.dictcategory.domain.service.DictCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/single-window/dict-category-list")
public class DictCategoryResource {

    @Autowired
    private DictCategoryService dictCategoryService;

    /**
     * 保存字典类别列表
     *
     * @param categoryList 字典
     */
    @PostMapping
    public void saveDictCategoryList(@RequestBody String categoryList) {
        dictCategoryService.save(categoryList);
    }


    /**
     * 保存字典项
     *
     * @param categoryItems 字典项
     */
    @PostMapping("/category-item")
    public void saveDictCategoryItemList(@RequestBody String categoryItems) {
        dictCategoryService.saveDictCategoryItem(categoryItems);
    }

    /**
     * 获取字典项
     *
     * @return
     */
    @GetMapping("{categoryCode}/category-item")
    public String getDictCategory(@PathVariable String categoryCode) {
        return dictCategoryService.getDictCategory(categoryCode);
    }

    /**
     * 判断字典项是否存在
     *
     * @return
     */
    @GetMapping("{categoryCode}/category-item-exists")
    public boolean existsDictCategory(@PathVariable String categoryCode) {
        return dictCategoryService.existsDictCategory(categoryCode);
    }
}
